forum

Home / DeveloperSection / Forums / Finding the minimum value in c#

Finding the minimum value in c#

Lady Bird Johnson197705-Oct-2013

I have this pretty simple code:

static void Main(string[] args) 
{
    int i, pcm, maxm = 0, minm = 0;
    for (i = 1; i <= 3; i++)
    {
        if (pcm > maxm)
            maxm = pcm;
        Console.WriteLine("Please enter your computer marks");
        pcm = int.Parse(Console.ReadLine());
    }
    Console.ReadKey();
}

As you can see I have the var pcm and maxm(maximum value), to find the maximum value I got this code : if (pcm > maxm) maxm = pcm;, I would like to get the minm(minimum value) in the same way I got the maxim(maximum value). how could I do that?


Updated on 05-Oct-2013

Can you answer this question?


Answer

1 Answers

Liked By